.\"	$NetBSD$
.\"	$Id: ccom.1,v 1.9 2010/04/05 13:13:57 reed Exp $
.\"
.\" Copyright (c) 2007 Jeremy C. Reed <reed@reedmedia.net>
.\" Permission to use, copy, modify, and/or distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM
.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND
.\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
.\" THIS SOFTWARE.
.Dd September 14, 2007
.Dt CCOM 1
.Os
.Sh NAME
.Nm ccom
.Nd C compiler
.Sh SYNOPSIS
.Nm
.Op Fl gs
.Op Fl W Ar flags
.Op Fl X Ar flags
.Op Fl x Ar optimizations
.Op Fl Z Ar flags
.Op infile
.Op outfile
.Sh DESCRIPTION
The
.Nm
utility provides a C compiler.
The frontend is usually
.Xr pcc 1 .
It is
.Em not
intended to be run directly.
.Pp
.Nm
reads the C source from
.Ar infile
or standard input and writes the assembler source
to
.Ar outfile
or to standard output.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl g
Enable debugging.
.\" built into binary, explain stabs?
.It Fl k
Generate PIC code.
.It Fl s
Print statistics to standard error when complete.
This includes:
name table entries, name string size, permanent allocated memory,
temporary allocated memory, lost memory, argument list unions,
dimension/function unions, struct/union/enum blocks, inline node count,
inline control blocks, and permanent symtab entries.
.\" TODO: explain units for above?
.It Fl v
Display version.
.It Fl W Ar flags
Report warnings.
(Do some basic checks.)
.Em NOTE!
.Em These are subject to change RSN!
.Ar flags
is one or more of the following:
.Bl -tag -width Ds
.It Sy error
Report all warnings as errors.
.It Sy implicit
Implies
.Sy implicit-function-declaration
and
.Sy implicit-int .
.It Sy implicit-function-declaration
Report if no prototype was declared for a function.
.It Sy implicit-int
TODO
.It Sy missing-prototypes
TODO
.It Sy strict-prototypes
TODO
.It Sy W
Enable all warnings.
.El
.\"
.It Fl X Ar flags
C specific debugging where
.Ar flags
is one or more of the following:
.Bl -tag -width Ds
.It Sy b
Building of parse trees
.It Sy d
Declarations (using multiple
.Sy d
flags gives more output)
.It Sy e
Pass1 trees at exit
.It Sy i
Initializations
.It Sy n
Memory allocations
.It Sy o
Turn off optimisations
.It Sy p
Prototypes
.It Sy s
Inlining
.It Sy t
Type conversions
.It Sy x
Target-specific flag, used in machine-dependent code
.El
.\"
.It Fl x Ar optimizations
.Ar optimizations
is one of the following:
.\" TODO: reword this, since multiple terms don't go with one -x switch??
.Bl -tag -width deljumps
.It Sy deljumps
Delete redundant jumps and dead code.
.It Sy ssa
Convert statements into SSA form for optimization.
Not yet finished.
.It Sy tailcall
Currently not implemented.
.It Sy temps
Setting this flag allows variables to be put into registers, for further
optimization by the register allocator.
.El
The
.Fl x
flag can be passed multiple times to set different options.
.\"
.It Fl Z Ar flags
Code generator (pass2) specific debugging where
.Ar flags
is one or more of the following:
.Bl -tag -width Ds
.It Sy b
Basic block and SSA building
.It Sy c
Code printout
.It Sy e
Trees when entering pass2
.It Sy f
Instruction matcher, may provide much output
.It Sy n
Memory allocation
.It Sy o
Instruction generator
.It Sy r
Register allocator
.It Sy s
Shape matching in instruction generator
.It Sy t
Type matching in instruction generator
.It Sy u
Sethi-Ullman computations
.It Sy x
Target-specific flag, used in machine-dependent code
.El
.El
.Sh SEE ALSO
.Xr as 1 ,
.Xr cpp 1 ,
.Xr pcc 1
.Sh HISTORY
The
.Nm
compiler is based on the original Portable C Compiler by S. C. Johnson,
written in the late 70's.
Even though much of the compiler has been rewritten, some of the
basics still remain.
About 50% of the frontend code and 80% of the backend code has been
rewritten.
Most is written by Anders Magnusson, with the exception of
the data-flow analysis part and the SSA conversion code which is
written by Peter A Jonsson, and the Mips port that were written as
part of a project by undergraduate students at Lulea University of
Technology.
.Pp
This product includes software developed or owned by Caldera
International, Inc.
